package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbUserMapper;
import com.dongdongshop.pojo.TbUser;
import com.dongdongshop.pojo.TbUserExample;
import com.dongdongshop.service.TbUserServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class TbUserServiceImpl implements TbUserServiceI {

    @Autowired
    private TbUserMapper tbUserMapper;

    @Override
    public void saveTbuser(TbUser tbUser) {
        tbUserMapper.insertSelective(tbUser);

    }

    @Override
    public TbUser getTbUser(String username) {
        TbUserExample example = new TbUserExample();
        TbUserExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<TbUser> list = tbUserMapper.selectByExample(example);
        return (list == null || list.size() <= 0) ? null : list.get(0);
    }
}
